<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>
	<title>Destroydrop &raquo; Javascripts &raquo; Tree</title>

	<link rel="StyleSheet" href="${base}/admin/dtree/dtree.css" type="text/css" />
	<script type="text/javascript" src="${base}/admin/js/jquery-1.7.min.js"></script>
	<script type="text/javascript" src="${base}/admin/dtree/dtree.js"></script>
	<script type="text/javascript" src="${base}/admin/contextmenu/jquery.contextmenu.js"></script>
	
	<style type="text/css">
		* {font-size:13px;}
		.contextMenu{display.none;}
	</style>

</head>

<body>
<div class="dtree">
	<form name="formCategory" id="category">
		<a href="javascript:ds.openAll();" >展开所有</a> | 
		<a href="javascript:ds.closeAll();" >关闭所有</a> |
		<input type="button" value="确定" onclick="ok()" /> | 
		<input type="button" value="取消" onclick="cancel()" /> | 
		<input type="button" value="清除" onclick="clean()" />
		<br/><br/>
		
	<!--<textarea id="text" style=" width:400px; height:100px;"></textarea>-->
		
	<script type="text/javascript">

		ds = new dTree('ds');
		ds.add(0,-1,'<span sytle="font-size:30px;"><b>店铺分类列表</b></span>');
		
		
		<#list brandCategoryList as category>
			ds.add(${treeMap[category.id]},${(treeMap[category.parent.id])!'0'},'<input type="radio" name="radioCategory" id="${category.id}" value="${category.name}" />${(category.name)!''}','javascript:click(\'${category.id}\');','点击查看','category_main','dtree/img/folder.gif','dtree/img/folderopen.gif');
		</#list>
		
		
		document.write(ds);
		
		//$("#text").val(ds);
		
		function cancel(){
			parent.$.fancybox.close();
		}
		
		function click(id){
			document.getElementById(id).checked=!document.getElementById(id).checked;
		}
		
		function clean(){
			parent.document.getElementById("storeCategory.parentName").value="";
			parent.document.getElementById("storeCategory.parentId").value="";
			parent.$.fancybox.close();
		}
		
		function ok(){
			if(formCategory.radioCategory.length>1){
				for(var i=0;i<formCategory.radioCategory.length;i++){
					if(formCategory.radioCategory[i].checked){
						parent.document.getElementById("parentName").value=formCategory.radioCategory[i].value;
						parent.document.getElementById("parentId").value=formCategory.radioCategory[i].id;
						parent.$.fancybox.close();
						return;
					}
				}
			}else{
				if(formCategory.radioCategory.checked){
						parent.document.getElementById("parentName").value=formCategory.radioCategory.value;
						parent.document.getElementById("parentId").value=formCategory.radioCategory.id;
						parent.$.fancybox.close();
						return;
				}
			}
			
			alert("未选择分类");
		}
		
		
		//勾选
		window.onload=function(){
			var cid=parent.document.getElementById("storeCategoryParentId").value;
			if(cid!=null&&cid!=""){
				document.getElementById(parent.document.getElementById("storeCategoryParentId").value).checked=true;
			}
			//展开当前节点
			ds.openTo($("#"+cid).parent().prev().attr("id").substr(ds.obj.length+1));
		};
			
	</script>
	</form>
</div>

</body>

</html>